package com.zy.ioc.pro2_ioc;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @program: mavenTest153
 * @description:
 * @author: zy
 * @create: 2025-07-12 16:02
 */
public class App1 {
    public static void main(String[] args) throws InterruptedException, SQLException {
        ApplicationContext ac=new AnnotationConfigApplicationContext(AppConfig.class);
        Product p= (Product) ac.getBean("product");
        System.out.println(p);

//        ThreadPoolExecutor executor= (ThreadPoolExecutor) ac.getBean("tpe");
//        executor.submit(  new Runnable(){
//            @Override
//            public void run() {
//                while( true ) {
//                    try {
//                        Thread.sleep(1000);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                    System.out.println( new Date() );
//                }
//
//            }
//        });
//
//        for(int i=0;i<100;i++){
//            System.out.println("我是主线程...");
//            Thread.sleep( 2000);
//        }


        DruidDataSource dds= (DruidDataSource) ac.getBean("ds");
        Connection con=dds.getConnection();
        System.out.println(con);
    }
}
